(function (vc, vm) {

    vc.extends({
        data: {
            withholdIntegralInfo: {
              
                integralId: '',
                integralName: '',
                communityId: '',
                amount: '',
                applyAmount:'',
                applyUserName: '',
                applyUserTel: '',
                remark: '',
                bankNum:'',
                bankNumName:'',
                bankName:'',
                mallApiCode:'applyIntegralWithdrawalBmoImpl'

            }
        },
        _initMethod: function () {

        },
        _initEvent: function () {
            vc.on('withholdIntegral', 'openWithholdIntegralModal', function (_params) {
                $that.refreshWithholdIntegralInfo();
                $('#withholdIntegralModel').modal('show');
                vc.copyObject(_params, $that.withholdIntegralInfo);
                $that.withholdIntegralInfo.applyAmount = _params.amount;
                $that.withholdIntegralInfo.communityId = vc.getCurrentCommunity().communityId;

                let userInfo = vc.getData('/nav/getUserInfo');
                $that.withholdIntegralInfo.applyUserName = userInfo.name;
                $that.withholdIntegralInfo.applyUserTel = userInfo.tel;
            });
        },
        methods: {
            withholdIntegralValidate: function () {
                return vc.validate.validate({
                    withholdIntegralInfo: $that.withholdIntegralInfo
                }, {
                    'withholdIntegralInfo.integralId': [
                        {
                            limit: "required",
                            param: "",
                            errInfo: "金币ID不能为空"
                        },
                        {
                            limit: "maxLength",
                            param: "30",
                            errInfo: "金币ID不能超过30"
                        },
                    ],
                   
                    'withholdIntegralInfo.applyAmount': [
                        {
                            limit: "required",
                            param: "",
                            errInfo: "提现积分不能为空"
                        },
                        {
                            limit: "maxLength",
                            param: "10",
                            errInfo: "提现积分不能超过10"
                        },
                    ],
                });
            },
            withholdIntegral: function () {
                if (!$that.withholdIntegralValidate()) {
                    vc.toast(vc.validate.errInfo);
                    return;
                }

                let _data = $that.withholdIntegralInfo;

                vc.http.apiPost(
                    '/mall.postMallOpenApi',
                    JSON.stringify(_data),
                    {
                        emulateJSON: true
                    },
                    function (json, res) {
                        //vm.menus = vm.refreshMenuActive(JSON.parse(json),0);
                        let _json = JSON.parse(json);
                        if (_json.code == 0) {
                            //关闭model
                            $('#withholdIntegralModel').modal('hide');
                            vc.emit('communityIntegral', 'listGoldWithdrawal', {});
                            return;
                        }
                        vc.toast(_json.msg);
                    },
                    function (errInfo, error) {
                        console.log('请求失败处理');

                        vc.toast(errInfo);
                    });
            },
            refreshWithholdIntegralInfo: function () {
                $that.withholdIntegralInfo = {
                    integralId: '',
                    integralName: '',
                    communityId: '',
                    amount: '',
                    applyAmount:'',
                    applyUserName: '',
                    applyUserTel: '',
                    remark: '',
                    bankNum:'',
                    bankNumName:'',
                    bankName:'',
                    mallApiCode:'applyIntegralWithdrawalBmoImpl'
                }
            }
        }
    });

})(window.vc, window.$that);
